import {} from "react";
import { Cell, Image } from "react-vant";
import { Button } from "antd-mobile";
import { useNavigate } from "react-router-dom";
import { FireO, LocationO } from "@react-vant/icons";

const Index = () => {
  const navigate = useNavigate();
  //获取用户信息
  const userInfo = JSON.parse(localStorage.getItem("userInfo") || "{}");

  //退出登录
  const outLogin = () => {
    localStorage.removeItem("userInfo");
    localStorage.removeItem("token");
    navigate("/login");
  };

  return (
    <div>
      <Cell
        center
        title={`用户 ${userInfo.username}`}
        label={"用户昵称：" + userInfo.nickname}
        icon={<Image width={44} height={44} src={userInfo.avatar} round />}
        rightIcon={<span></span>}
        isLink
      />
      <div>
        <Cell title="用户管理" icon={<LocationO />} />
        <Cell
          title="乘车人管理"
          icon={<FireO />}
          onClick={() => navigate("/addtickperson")}
        />
        <Cell title="收藏列表" icon={<FireO />} />
        <Cell title="地址管理" icon={<LocationO />} />
        <Cell title="行程管理" icon={<FireO />} />
        <Button block color="danger" size="large" onClick={() => outLogin()}>
          退出登录
        </Button>
      </div>
    </div>
  );
};

export default Index;
